import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/get_mqtt_info_entity.dart';
import 'package:flutter_deer/res/constant.dart';

import 'package:sp_util/sp_util.dart';


GetMqttInfoEntity $GetMqttInfoEntityFromJson(Map<String, dynamic> json) {
  final GetMqttInfoEntity getMqttInfoEntity = GetMqttInfoEntity();
  final int? isSuperuser = jsonConvert.convert<int>(json['isSuperuser']);
  if (isSuperuser != null) {
    getMqttInfoEntity.isSuperuser = isSuperuser;
  }
  final GetMqttInfoMqttInfo? mqttInfo = jsonConvert.convert<GetMqttInfoMqttInfo>(json['mqttInfo']);
  if (mqttInfo != null) {
    getMqttInfoEntity.mqttInfo = mqttInfo;
  }
  final String? password = jsonConvert.convert<String>(json['password']);
  if (password != null) {
    getMqttInfoEntity.password = password;
  }
  final String? username = jsonConvert.convert<String>(json['username']);
  if (username != null) {
    getMqttInfoEntity.username = username;
  }
  return getMqttInfoEntity;
}

Map<String, dynamic> $GetMqttInfoEntityToJson(GetMqttInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['isSuperuser'] = entity.isSuperuser;
  data['mqttInfo'] = entity.mqttInfo?.toJson();
  data['password'] = entity.password;
  data['username'] = entity.username;
  return data;
}

extension GetMqttInfoEntityExtension on GetMqttInfoEntity {
  GetMqttInfoEntity copyWith({
    int? isSuperuser,
    GetMqttInfoMqttInfo? mqttInfo,
    String? password,
    String? username,
  }) {
    return GetMqttInfoEntity()
      ..isSuperuser = isSuperuser ?? this.isSuperuser
      ..mqttInfo = mqttInfo ?? this.mqttInfo
      ..password = password ?? this.password
      ..username = username ?? this.username;
  }
}

GetMqttInfoMqttInfo $GetMqttInfoMqttInfoFromJson(Map<String, dynamic> json) {
  final GetMqttInfoMqttInfo getMqttInfoMqttInfo = GetMqttInfoMqttInfo();
  final String? host = jsonConvert.convert<String>(json['host']);
  if (host != null) {
    getMqttInfoMqttInfo.host = host;
  }
  final int? port = jsonConvert.convert<int>(json['port']);
  if (port != null) {
    getMqttInfoMqttInfo.port = port;
  }
  final String? protocol = jsonConvert.convert<String>(json['protocol']);
  if (protocol != null) {
    getMqttInfoMqttInfo.protocol = protocol;
  }
  final String? pullInterval = jsonConvert.convert<String>(json['pullInterval']);
  if (pullInterval != null) {
    getMqttInfoMqttInfo.pullInterval = pullInterval;
  }
  final String? receipt = jsonConvert.convert<String>(json['receipt']);
  if (receipt != null) {
    getMqttInfoMqttInfo.receipt = receipt;
  }
  final List<String>? subscribes = (json['subscribes'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (subscribes != null) {
    getMqttInfoMqttInfo.subscribes = subscribes;
  }
  return getMqttInfoMqttInfo;
}

Map<String, dynamic> $GetMqttInfoMqttInfoToJson(GetMqttInfoMqttInfo entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['host'] = entity.host;
  data['port'] = entity.port;
  data['protocol'] = entity.protocol;
  data['pullInterval'] = entity.pullInterval;
  data['receipt'] = entity.receipt;
  data['subscribes'] = entity.subscribes;
  return data;
}

extension GetMqttInfoMqttInfoExtension on GetMqttInfoMqttInfo {
  GetMqttInfoMqttInfo copyWith({
    String? host,
    int? port,
    String? protocol,
    String? pullInterval,
    String? receipt,
    List<String>? subscribes,
  }) {
    return GetMqttInfoMqttInfo()
      ..host = host ?? this.host
      ..port = port ?? this.port
      ..protocol = protocol ?? this.protocol
      ..pullInterval = pullInterval ?? this.pullInterval
      ..receipt = receipt ?? this.receipt
      ..subscribes = subscribes ?? this.subscribes;
  }
}